using System;
using System.Windows;
namespace Microsoft.Expression.Interactivity.Core
{
	public class DataTrigger : PropertyChangedTrigger
	{
		public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(object), typeof(DataTrigger), new PropertyMetadata(new PropertyChangedCallback(DataTrigger.OnValueChanged)));
		public static readonly DependencyProperty ComparisonProperty = DependencyProperty.Register("Comparison", typeof(ComparisonConditionType), typeof(DataTrigger), new PropertyMetadata(new PropertyChangedCallback(DataTrigger.OnComparisonChanged)));
		public object Value
		{
			get
			{
				return base.GetValue(DataTrigger.ValueProperty);
			}
			set
			{
				base.SetValue(DataTrigger.ValueProperty, value);
			}
		}
		public ComparisonConditionType Comparison
		{
			get
			{
				return (ComparisonConditionType)base.GetValue(DataTrigger.ComparisonProperty);
			}
			set
			{
				base.SetValue(DataTrigger.ComparisonProperty, value);
			}
		}
		protected override void EvaluateBindingChange(object args)
		{
			if (this.Compare())
			{
				base.InvokeActions(args);
			}
		}
		private static void OnValueChanged(object sender, DependencyPropertyChangedEventArgs e)
		{
			DataTrigger dataTrigger = (DataTrigger)sender;
			dataTrigger.EvaluateBindingChange(e);
		}
		private static void OnComparisonChanged(object sender, DependencyPropertyChangedEventArgs e)
		{
			DataTrigger dataTrigger = (DataTrigger)sender;
			dataTrigger.EvaluateBindingChange(e);
		}
		private bool Compare()
		{
			return base.AssociatedObject != null && ComparisonLogic.EvaluateImpl(base.Binding, this.Comparison, this.Value);
		}
	}
}
